import { ref } from "vue";
import { defineStore } from "pinia";

export const useNoticeStore = defineStore(
  "notice",
  () => {
    const noticeList = ref([{time: "2025-01-01 12:00:00",text: "地下网线抢修，预计六小时内完成"}, {time: "2025-01-20 12:00:00", text: "道路养护，预计三小时内完成"}]);
// 添加公告
    const addNotice = (item) => {
      noticeList.value.push(item);
    };
// 删除公告
    const removeNotice = (index) => {
      noticeList.value.splice(index, 1);
    };
    return { noticeList, addNotice, removeNotice };
  },
  {
    persist: true,
  }
);
